<?php
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

class rcbaseViewMotorList extends JView
{
	function display($tpl = null)
	{
		$task_hdl = array(
			'motorlist' => 'motor_list',
			'search' => 'search_page',
		);
		$task = JRequest::getVar( 'task', 'motor_list' );
		$method = ($task_hdl[$task] ? $task_hdl[$task] : 'motor_list');
		$this->$method();
	}

	function motor_list($tpl = null){
		$model =& $this->getModel();
		$search_data = $model->getMotorList();;

		$data = array(
			'model' => $model,
			'search' => $search_data,
		);
		$this->assignRef( 'data',	$data );

		$doc =& JFactory::getDocument();
		$doc->setTitle( 'База данных по ВМГ::Список моторов' );
		$doc->addScript('components/com_rcbase/js/jquery-ui/js/jquery-1.7.1.min.js');

		parent::display($tpl);
	}

	function search_page($tpl = null){
		$model =& $this->getModel();

		$search_data = $model->getSearchResult();

		$data = array(
			'model' => $model,
			'search' => $search_data,
		);
		$this->assignRef( 'data',	$data );

		$doc =& JFactory::getDocument();
		$doc->setTitle( 'База данных по ВМГ::Подбор ВМГ' );

		$doc->addStyleSheet('components/com_rcbase/js/jquery-ui/css/south-street/jquery-ui-1.8.17.custom.css');
		$doc->addScript('components/com_rcbase/js/jquery-ui/js/jquery-1.7.1.min.js');
		$doc->addScript('components/com_rcbase/js/jquery-ui/js/jquery-ui-1.8.17.custom.min.js');

		$mainframe =& JFactory::getApplication();
		$pathway   =& $mainframe->getPathway();
		$pathway->addItem('Подбор ВМГ', '');

		parent::setLayout('searchpage');
		parent::display($tpl);
	}

}